package com.example.keli.ui.my.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.keli.R;
import com.example.keli.base.adapter.CommonAdapter;
import com.example.keli.base.adapter.ViewHolder;
import com.example.keli.ui.my.model.MyGridModel;

import java.util.ArrayList;
import java.util.List;

public class GridAdapter extends CommonAdapter<MyGridModel> {
    private static final String TAG = "GridAdapter";
    private Context context;
    private List<MyGridModel> mDatas = new ArrayList<>();

    public GridAdapter(Context context, List<MyGridModel> mDatas, int itemLayoutId) {
        super(context, mDatas, itemLayoutId);
        this.context = context;
        this.mDatas.addAll(mDatas);
    }

    @Override
    public void convert(final ViewHolder helper, final MyGridModel tagModel) {
        TextView name = helper.getView(R.id.tv_name);
        TextView size = helper.getView(R.id.tv_size);
        ImageView image = helper.getView(R.id.iv_img);

        if (TextUtils.isEmpty(tagModel.getSize())){
            size.setVisibility(View.GONE);
        }else {
            size.setText(tagModel.getSize());
        }
        name.setText(tagModel.getName());
        image.setImageResource(tagModel.getImage());

//
    }

}